package com.fly.controller;

import com.fly.service.StuService;
import com.fly.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/passport")
public class PassportController {

    @Autowired
    private UserService userService;

    @GetMapping("/usernameIsExit")
    public HttpStatus usernameIsExits(@RequestParam String username){

        if (StringUtils.isBlank(username)){ //入参数校验

            System.out.println("用户名不能为空");
            return HttpStatus.INTERNAL_SERVER_ERROR;
        }
        //查找已存在的用户名
        boolean isExist = userService.queryUsernameIsExits(username);

        //存在返回500
        if (isExist){
            System.out.println("用户名已经存在");
            return  HttpStatus.INTERNAL_SERVER_ERROR;
        }

        //请求成功
        return HttpStatus.OK;
    }


}
